package org.groupg.practice;

import org.apache.juneau.http.response.Ok;
import org.apache.juneau.rest.client.RestClient;
import org.groupg.practice.juneau.CreatePet;
import org.groupg.practice.juneau.PetStoreClient;

import java.io.IOException;
import java.util.UUID;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.
        System.out.printf("Hello and welcome!");

        for (int i = 1; i <= 5; i++) {
            //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
            // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
            System.out.println("i = " + i);
        }
        // Use a RestClient with default JSON 5 support and BASIC auth.
        PetStoreClient store;
        try (RestClient client = RestClient.create().json5().basicAuth("", 8000, "", "").build()) {

            // Instantiate our proxy interface.
            store = client.getRemote(PetStoreClient.class, "http://localhost:10000");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        // Use it to create a pet.
        CreatePet createPet = new CreatePet("Fluffy", 9.99);
        Ok ok = store.addPet(createPet, UUID.randomUUID(), true);
    }
}